﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>员工薪资列表</title>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
	
	<script type="text/javascript">
	   $(function(){
	     //页面一打开 加载工资单数据
		 getAll(1);
		 
		 //按钮点击，再次发送异步请求
		 $("#but").click(function(){
		    getAll(1);
		 });  
		 
		 //分页加动作
		  $("body").on("click","#pagediv li a",function(){
		    var pp = $(this).attr("name"); 
		    getAll(pp);   
		 });  
		 	    
      });
      
    //查询工资单
	function getAll(pa)
	{
	   var str=$("#queryform").serialize()+"&page="+pa;
	   $.getJSON("salary/list.action",str,function(pbean){
	      $("#salbody").html("");
	        for(var i=0;i<pbean.list.length;i++)
	        {      
	           var us_name="";var de_name="";
               if(pbean.list[i].empxx.us_name!=null)  us_name=pbean.list[i].empxx.us_name;
               if(pbean.list[i].empxx.us_depid.de_name!=null)  de_name=pbean.list[i].empxx.us_depid.de_name;
	           var newtr=$("<tr class='text-c'></tr>");
	          /*  newtr.append("<td><input type='checkbox'></td>"); */
	           newtr.append("<td>"+pbean.list[i].empxx.us_id+"</td>");
	           newtr.append("<td><u style='cursor:pointer;text-decoration:none;'class='text-primary'"
	            +"onclick=\"member_show('增加页面','salary/addsal.action?id="+pbean.list[i].empxx.us_id+"&said="+pbean.list[i].sa_id+"','2','800','500')\">"+us_name+"</u></td>"); 
	           newtr.append("<td>"+pbean.list[i].sa_totalmoney+"</td>");
	           newtr.append("<td>"+pbean.list[i].sa_base+"</td>");
	           /* newtr.append("<td>"+pbean.list[i].sa_remark+"</td>"); */
	           newtr.append("<td>"+toTime(pbean.list[i].sa_createtime)+"</td>");
	           newtr.append("<td>"+pbean.list[i].sa_id+"</td>");
	           newtr.append("<td>"+de_name+"</td>"); 
	           newtr.append("<td>"+pbean.list[i].empxx.us_depid.de_id+"</td>"); 
	           newtr.append("<td class='td-status'><span class='label label-success radius'>"+pbean.list[i].sa_status+"</span></td>");
	          
	           if(pbean.list[i].sa_status=='待审批' || pbean.list[i].sa_status=='通过') 
               newtr.append("<td class='td-manage'></td>");
               else if(pbean.list[i].sa_status=='拒绝') 
               newtr.append("<td class='td-manage'>"+
                              "<i class='Hui-iconfont'>&#xe6df;</i></a>"+
					          "<a title='删除' href='salary/modstu.action?sa_id="+pbean.list[i].sa_id+"'>"
					        +"</td>");
	           else if(pbean.list[i].sa_status=='新增' || pbean.list[i].sa_status=='打回') 
	           newtr.append("<td class='td-manage'>"+
					          "<a title='修改' href='javascript:;' onclick=\"member_edit('修改','salary/getbyid.action?&sa_id="+pbean.list[i].empxx.us_id+"&said="+pbean.list[i].sa_id+"','4','','510')\" class='ml-5' style='text-decoration:none'>"+
					          "<i class='Hui-iconfont'>&#xe6df;</i></a>"+
					          "<a title='删除' href='salary/modstu.action?sa_id="+pbean.list[i].sa_id+"'>"+
					          /* javascript:;' onclick=\"member_del('salary/modstu.action?sa_id='"+pbean.list[i].sa_id+"','1')\" class='ml-5' style='text-decoration:none' */
					          "<i class='Hui-iconfont'>&#xe6e2;</i></a>"+
					          "<a title='提交' href='salary/up_check.action?sa_id="+pbean.list[i].sa_id+"&did="+pbean.list[i].empxx.us_depid.de_id+"'>"+
					          /*javascript:;' onclick=\"member_edit('提交','salary_apply1.jsp','4','','510')\" class='ml-5' style='text-decoration:none'> */
					          "<i class='Hui-iconfont'>&#xe642;</i></a>"+
				            "</td>");
		      	           $("#salbody").append(newtr);
	         } 

	        //处理分页
	        $("#pagediv").html("");
	        $("#pagediv").append("<span>共有数据：<strong>"+pbean.totalRow+"</strong> 条，当前显示第&nbsp;<strong>"+pbean.currpage+"&nbsp;</strong>页</span>");
	        var newul=$("<ul style='float:right;'></ul>");
	        //上一页
	        newul.append("<li style='float:left;'><a href='javascript:void(0)' name='"+(pbean.currpage-1)+"' class='btn btn-primary radius'><</a></li>");
	        
	        for( var i=1;i<=pbean.totalpage;i++)
	        {
	           newul.append("<li style='float:left;'><a href='javascript:void(0)' name='"+i+"'>&nbsp;"+i+"&nbsp;</a></li>");
	        }
	        
	        //下一页
	         newul.append(" <li style='float:left;'><a href='javascript:void(0)'  name='"+(pbean.currpage+1)+"'  class='btn btn-primary radius'>></a></li>");
	        $("#pagediv").append(newul) ;
	        
	       })
	      }

	function toTime(timestamp) {
	   var date = new Date(timestamp);
	   Y = date.getFullYear() + '-';
	   M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
	   D = date.getDate() + ' ';
	   h = date.getHours() + ':';
	   m = (date.getMinutes() < 10 ? '0'+(date.getMinutes()) : date.getMinutes()) + ':';
	   s = (date.getSeconds() < 10 ? '0'+(date.getSeconds()) : date.getSeconds());
	   return Y+M+D+h+m+s;
	}
      
	
	</script>
	
	
</head>
<body>
  <nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 用户中心 
    <span class="c-gray en">&gt;</span> 用户管理
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
      <i class="Hui-iconfont">&#xe68f;</i>
    </a>
  </nav>
<div class="page-container">
  
	<div class="text-c">
	<form id="queryform">
	   日期范围：
		<input type="text" name="begin" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" name="end" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;">
		<input type="text" name="ename" class="input-text" style="width:120px" placeholder="输入员工姓名"><br>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		金&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;额：
		<input type="text" name="minsal" class="input-text"  style="width:120px;">
		-
		<input type="text" name="maxsal" class="input-text"  style="width:120px;">
		<input type="text" name="depname" class="input-text" style="width:120px" placeholder="输入部门姓名">
		<button type="button" class="btn btn-success radius" id="but"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	  </form>
	</div>
  
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
	   <span class="l">
	     <a href="salary/export.action" class="btn btn-success radius">
	      <i class="Hui-iconfont">&#xe6e2;</i> 导出
	    </a> 
	  <!--   <a href="javascript:;" onclick="member_add('添加用户','salary_add.jsp','','510')" class="btn btn-primary radius">
	      <i class="Hui-iconfont">&#xe600;</i> 导入
	    </a> -->
	  </span> 
	  <span class="r">共有数据：<strong>${pb.totalRow}</strong> 条</span>
   </div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg ">
		<thead>
			<tr class="text-c">
				<!-- <th width="25"><input type="checkbox" name="" value=""></th> -->
				<th width="80">员工编号</th>
				<th width="100">姓名</th>
				<th width="90">总工资</th>
				<th width="100">基本工资</th>
				<!-- <th width="150">备注</th> -->
				<th width="130">创建时间</th>
				<th width="80">薪资标准</th>
				<th width="30">部门</th>
				<th width="30">部门编号</th>
				<th width="70">状态</th>
				<th width="120">操作</th>
			</tr>
		</thead>
		<tbody id="salbody">
		
		</tbody>
	 </table>
	
	</div>
	 <div id="pagediv">
	
	</div>
	
</div>



<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
$(function(){
	$('.table-sort').dataTable({
		"aaSorting": [[ 1, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[0,8,9]}// 制定列不参与排序
		]
	});
	
});
/*用户-添加*/
function member_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*用户-查看*/
function member_show(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*用户-停用*/
/* function member_stop(obj,id){
	layer.confirm('确认要停用吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '',
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>');
				$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
				$(obj).remove();
				layer.msg('已停用!',{icon: 5,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}

//用户-启用
function member_start(obj,id){
	layer.confirm('确认要启用吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '',
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>');
				$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
				$(obj).remove();
				layer.msg('已启用!',{icon: 6,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});
	});
} */
/*用户-编辑*/
function member_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*密码-修改*/
/* function change_password(title,url,id,w,h){
	layer_show(title,url,w,h);	
} */
/*用户-删除*/
function member_del(url,id){
	//layer.confirm('确认要删除吗？',function(index){
		/* $.ajax({
			type: 'POST',
			url: 'salary/modstu.action',
			data:'sa_id='+pbean.list[i].sa_id,
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		 */
		  /*   var index = parent.layer.getFrameIndex(window.name);
			//parent.$('#addvou').click();
			window.parent.location.reload(); 
			parent.layer.close(index); */
	/* }); */
}
</script> 
</body>
</html>